﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;
using Dal;
using System.Data;

namespace Bll
{
    public class BllService
    {
        DalService d = new DalService();

        public DataTable Nav_Inquire_All()
        {
            //一级导航全部信息
            return d.Nav_Inquire_All();
        }//一级导航全部信息

        public int Service_Count_File_Number(ModelPublic m)
        {
            //统计资料文件当天个数
            return d.Service_Count_File_Number(m);
        }//统计资料文件当天个数

        public string Service_Add(ModelPublic m)
        {
            if(m.Type=="0")
            {
                if (m.Title == "")
                    return "请输入指南标题！";
                if (m.Adress == "")
                    return "请输入指南链接地址！";
            }
            if(m.Type=="1")
            {
                if (m.Title == "")
                    return "请输入指南标题！";
                if (m.DateTime == "")
                    return "请输入指南时间！";
                if (m.Author == "")
                    return "请输入指南作者！";
                if (m.Content == "")
                    return "请输入指南内容！";
            }

            //服务指南添加
            if (!d.Service_IsTitle(m))
            {
                if (d.Service_Add(m))
                    return "1";
                else
                    return "添加失败！";
            }
            else
                return "指南已存在！";
           
        }

        public DataTable Service_Inquire_All(ModelPublic m)
        {
            //获取全部信息(发布版)
            return d.Service_Inquire_All(m);
        }//获取全部信息(发布版)

        public DataTable Service_Inquire_All_Unpublished(ModelPublic m)
        {
            //获取全部信息(未发布版)
            return d.Service_Inquire_All_Unpublished(m);
        }//获取全部信息(未发布版)

        public DataTable Service_Inquire_Single(ModelPublic m)
        {
            //查询单条信息
            return d.Service_Inquire_Single(m);
        }//查询单条信息

        public DataTable Service_Search_All(ModelPublic m)
        {
            //检索信息(发布版)
            return d.Service_Search_All(m);
        }//检索信息(发布版)

        public DataTable Service_Search_All_Unpublished(ModelPublic m)
        {
            //检索信息(未发布版)
            return d.Service_Search_All_Unpublished(m);
        }//检索信息(未发布版)

        public bool Service_Delete(ModelPublic m)
        {
            //信息删除
            return d.Service_Delete(m);
        }//信息删除

        public string Service_Modify(ModelPublic m)
        {
            //信息修改
            if (d.Service_Modify(m))
                return "1";
            else
                return "修改失败！";
        }//信息修改

        public bool Browse_Frequency(ModelPublic m)
        {
            //阅读次数增加
            return d.Browse_Frequency(m);
        }//阅读次数增加
    }
}
